package com.zd.ticketing.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.zd.common.common.utils.LogUtils;
import com.zd.ticketing.service.ITicketOrderService;

@Controller
@RequestMapping("pc/pickUp")
public class PCPickUpTticketController {
	
	@Autowired
	private ITicketOrderService ticketOrderService;
	
	
	
	
	@RequestMapping("/toPickUpTticket")
	public ModelAndView toPickUpTticket(){//取票
		ModelAndView mv = new ModelAndView();
		mv.setViewName("PC/pickUpTticket");
		return mv;
	}
	
	@RequestMapping("/toIdNumPick")
	public ModelAndView toIdNumPick(){
		ModelAndView mv = new ModelAndView();
		mv.setViewName("PC/idNumPick");
		return mv;
	}
	
	@RequestMapping("/toCheckCodePick")
	public ModelAndView toCheckCodePick(){//取票
		ModelAndView mv = new ModelAndView();
		mv.setViewName("PC/checkCodePick");
		return mv;
	}
	
	@RequestMapping("checkCodePick")
	public ModelAndView checkCodePick(String checkCode,String deviceNo)throws Exception{
		ModelAndView mv = new ModelAndView();
		Map<String, Object> resultMap = ticketOrderService.getTicketOrderDetailList(null, checkCode, deviceNo);
		mv.addObject("resultMap",resultMap );
		LogUtils.info(resultMap);
		mv.setViewName("PC/userTicket");
		return mv;
	}
	
	@RequestMapping("idNumPick")
	public ModelAndView idNumPick(String idNumber,String deviceNo)throws Exception{
		ModelAndView mv = new ModelAndView();
		Map<String, Object> resultMap = ticketOrderService.getTicketOrderDetailList(idNumber, null, deviceNo);
		mv.addObject("resultMap",resultMap );
		LogUtils.info(resultMap);
		mv.setViewName("PC/userTicket");
		return mv;
	}
	
	@ResponseBody
	@RequestMapping("/updatePrprint")
	public Map<String, String> updatePrprintStatus(Integer orderDetailId ,String deviceNo)throws Exception{
		Map<String, String> resultMap = new HashMap<>();
		resultMap = ticketOrderService.updatePcprintStatus(orderDetailId);
		return resultMap;
	}
	
	@RequestMapping("/getTicket")
	@ResponseBody
	public Map<String, Object> getTicket(Integer orderDetailId) throws Exception {
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("result", true);
		resultMap.putAll(ticketOrderService.getTicket(orderDetailId));
		return resultMap;
	}
	
}
